package com.hedl.practice.diyJava.methodAndStructure.structure;

public class StudyStructure {
    public static void main(String[] args) {

        Person p = new Person("小明",20);
        System.out.println(p);

        System.out.println("---------------------------");
        System.out.println(p.getName());
        System.out.println(p.getAge());

        System.out.println("============================");
        p.setName("张三");
        p.setAge(30);
        System.out.println(p.getName());
        System.out.println(p.getAge());

    }
}


//练习：工具类
class Person{
    private String name;
    private Integer age;

    public String getName(){
        return name;
    }

    public Integer getAge(){
        return age;
    }

    public void setName(String name){
        this.name = name;
    }
    public void setAge(Integer age){
        this.age = age;
    }

    public Person(){
    }

    public Person(String name,Integer age){
        this.name = name;
        this.age = age;
    }

    public String toString(){
        return "姓名："+name+"\n"+"年龄："+age;
    }
}